<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>flash.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
  </script>

  <script src="static/js/doc.js">
  </script>

  <meta charset="utf8">
</head>

<body onload="prettyPrint()">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_useragent_flash.js.html">flash.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line2"></a>// you may not use this file except in compliance with the License.
<a name="line3"></a>// You may obtain a copy of the License at
<a name="line4"></a>//
<a name="line5"></a>//     http://www.apache.org/licenses/LICENSE-2.0
<a name="line6"></a>//
<a name="line7"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line8"></a>// distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<a name="line9"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line10"></a>// See the License for the specific language governing permissions and
<a name="line11"></a>// limitations under the License.
<a name="line12"></a>
<a name="line13"></a>// Copyright 2006 Google Inc. All Rights Reserved.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Flash detection.
<a name="line17"></a> * @see ../demos/useragent.html
<a name="line18"></a> */
<a name="line19"></a>
<a name="line20"></a>goog.provide(&#39;goog.userAgent.flash&#39;);
<a name="line21"></a>
<a name="line22"></a>goog.require(&#39;goog.string&#39;);
<a name="line23"></a>
<a name="line24"></a>(function() {
<a name="line25"></a>  /**
<a name="line26"></a>   * Derived from Apple&#39;s suggested sniffer.
<a name="line27"></a>   * @param {string} desc e.g. Shockwave Flash 7.0 r61.
<a name="line28"></a>   * @return {string} 7.0.61.
<a name="line29"></a>   */
<a name="line30"></a>  function getFlashVersion(desc) {
<a name="line31"></a>    var matches = desc.match(/[\d]+/g);
<a name="line32"></a>    matches.length = 3;  // To standardize IE vs FF
<a name="line33"></a>    return matches.join(&#39;.&#39;);
<a name="line34"></a>  }
<a name="line35"></a>
<a name="line36"></a>  var hasFlash = false;
<a name="line37"></a>  var flashVersion = &#39;&#39;;
<a name="line38"></a>
<a name="line39"></a>  if (navigator.plugins &amp;&amp; navigator.plugins.length) {
<a name="line40"></a>    var plugin = navigator.plugins[&#39;Shockwave Flash&#39;];
<a name="line41"></a>    if (plugin) {
<a name="line42"></a>      hasFlash = true;
<a name="line43"></a>      if (plugin.description) {
<a name="line44"></a>        flashVersion = getFlashVersion(plugin.description);
<a name="line45"></a>      }
<a name="line46"></a>    }
<a name="line47"></a>
<a name="line48"></a>    if (navigator.plugins[&#39;Shockwave Flash 2.0&#39;]) {
<a name="line49"></a>      hasFlash = true;
<a name="line50"></a>      flashVersion = &#39;2.0.0.11&#39;;
<a name="line51"></a>    }
<a name="line52"></a>
<a name="line53"></a>  } else if (navigator.mimeTypes &amp;&amp; navigator.mimeTypes.length) {
<a name="line54"></a>    var mimeType = navigator.mimeTypes[&#39;application/x-shockwave-flash&#39;];
<a name="line55"></a>    hasFlash = mimeType &amp;&amp; mimeType.enabledPlugin;
<a name="line56"></a>    if (hasFlash) {
<a name="line57"></a>      flashVersion = getFlashVersion(mimeType.enabledPlugin.description);
<a name="line58"></a>    }
<a name="line59"></a>
<a name="line60"></a>  } else {
<a name="line61"></a>    /** @preserveTry */
<a name="line62"></a>    try {
<a name="line63"></a>      // Try 7 first, since we know we can use GetVariable with it
<a name="line64"></a>      var ax = new ActiveXObject(&#39;ShockwaveFlash.ShockwaveFlash.7&#39;);
<a name="line65"></a>      hasFlash = true;
<a name="line66"></a>      flashVersion = getFlashVersion(ax.GetVariable(&#39;$version&#39;));
<a name="line67"></a>    } catch (e) {
<a name="line68"></a>      // Try 6 next, some versions are known to crash with GetVariable calls
<a name="line69"></a>      /** @preserveTry */
<a name="line70"></a>      try {
<a name="line71"></a>        var ax = new ActiveXObject(&#39;ShockwaveFlash.ShockwaveFlash.6&#39;);
<a name="line72"></a>        hasFlash = true;
<a name="line73"></a>        flashVersion = &#39;6.0.21&#39;;  // First public version of Flash 6
<a name="line74"></a>      } catch (e2) {
<a name="line75"></a>        /** @preserveTry */
<a name="line76"></a>        try {
<a name="line77"></a>          // Try the default activeX
<a name="line78"></a>          var ax = new ActiveXObject(&#39;ShockwaveFlash.ShockwaveFlash&#39;);
<a name="line79"></a>          hasFlash = true;
<a name="line80"></a>          flashVersion = getFlashVersion(ax.GetVariable(&#39;$version&#39;));
<a name="line81"></a>        } catch (e3) {
<a name="line82"></a>          // No flash
<a name="line83"></a>        }
<a name="line84"></a>      }
<a name="line85"></a>    }
<a name="line86"></a>  }
<a name="line87"></a>
<a name="line88"></a>  /**
<a name="line89"></a>   * Whether we can detect that the browser has flash
<a name="line90"></a>   * @type {boolean}
<a name="line91"></a>   */
<a name="line92"></a>  goog.userAgent.flash.HAS_FLASH = hasFlash;
<a name="line93"></a>
<a name="line94"></a>
<a name="line95"></a>  /**
<a name="line96"></a>   * Full version information of flash installed, in form 7.0.61
<a name="line97"></a>   * @type {string}
<a name="line98"></a>   */
<a name="line99"></a>  goog.userAgent.flash.VERSION = flashVersion;
<a name="line100"></a>
<a name="line101"></a>})();
<a name="line102"></a>
<a name="line103"></a>
<a name="line104"></a>/**
<a name="line105"></a> * Whether the installed flash version is as new or newer than a given version.
<a name="line106"></a> * @param {string} version The version to check.
<a name="line107"></a> * @return {boolean} Whether the installed flash version is as new or newer
<a name="line108"></a> *     than a given version.
<a name="line109"></a> */
<a name="line110"></a>goog.userAgent.flash.isVersion = function(version) {
<a name="line111"></a>  return goog.string.compareVersions(goog.userAgent.flash.VERSION,
<a name="line112"></a>                                     version) &gt;= 0;
<a name="line113"></a>};
</pre>


</body>
</html>
